package cn.edu.neusoft.demo.hospital2.Dao;

import cn.edu.neusoft.demo.hospital2.pojo.Carousel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarouselDao extends BaseMapper<Carousel> {
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "img", column = "img"),
            @Result(property = "title", column = "title"),
            @Result(property = "content", column = "content"),
            @Result(property = "noticeId", column = "notice_id"),
            @Result(property = "isValid", column = "is_valid")
    })

    @Select("SELECT * FROM carousel")
    List<Carousel> selectAllValidCarousels();

    @Select("SELECT * FROM carousel WHERE id = #{id}")
    Carousel selectById(int id);

    @Insert("INSERT INTO carousel (img, title, content, notice_id, is_valid) VALUES (#{img}, #{title}, #{content}, #{noticeId}, #{isValid})")
    int insert(Carousel carousel);

    @Update("UPDATE carousel SET img = #{img}, title = #{title}, content = #{content}, notice_id = #{noticeId}, is_valid = #{isValid} WHERE id = #{id}")
    int update(Carousel carousel);

    @Delete("DELETE FROM carousel WHERE id = #{id}")
    int deleteById(int id);
}
